<{include file="tpl/admin/header.html"}>
<script type="text/javascript">
$(document).ready(function(){ // 当页面加载完毕的时候
	// 例子三
	$("#ex3button").click(function(){ // "提交"按钮被点击
		// 构造发送的数据，请注意如果获取表单各项的值
		var formdata = {
			'uname' : $('#uname').val(),
			'upass' : $('#upass').val(),
			'realname' : $('#realname').val(),
			'Phone' : $('#Phone').val(),
			'QQ' : $('#QQ').val(),
			'Email' : $('#Email').val(),
			'Address' : $('#Address').val(),
			'acl' : $('#acl').val(),
			'uid' : $('#uid').val()
		};
		var uid  = $('#uid').val();  // 根据有没有id 判断是编辑还是增加
		if(uid == '')
		{
			// 用$.post发送数据
			$.post('<{spUrl c=usersform a=adddata}>', formdata, function(result){
				$('#resulttable').append(result); // 返回的数据直接追加到resulttable表格的后面
				feedback(result,uid);
			});
		}
		else
		{
		   	// 用$.post发送数据
			$.post('<{spUrl c=usersform a=editdata}>', formdata, function(result){
				$('#resulttable').append(result); // 返回的数据直接追加到resulttable表格的后面
				feedback(result,uid);
			});	
		}
		
	});
});

function del(uid){
		$.get('<{spUrl c=usersform a=deldata}>', 'uid='+uid, function(result){
			$('#ex1result').html(result); // 返回的数据直接显示在id=ex1result的span中。
			if(result == 1)
			{alert('删除成功!!');}else{alert('删除失败!!')}
			window.location.reload(); 
		});
}
</script>
<div class="breadcrumbs">
	<div class="container-fluid">
		<ul class="bread pull-left">
			<li>
				<a href="index.php?c=usersform&a=index&t=user"><i class="icon-home icon-white"></i></a>
			</li>
			<li>
				<a href="index.php?c=usersform&a=index&t=user">
					用户管理
				</a>
			</li>
		</ul>

	</div>
</div>
<div class="main">
     <{include file="tpl/admin/left.html"}>
	<div class="container-fluid">
		<div class="content">
			<div class="row-fluid">
				<div class="span12">
					<div class="box">
						<div class="box-head tabs">
							<h3>用户管理 | <a href="index.php?c=usersform&a=index&t=user">添加</a></h3>
							<ul class='nav nav-tabs'>
								<li class='active'>
									<a href="#basic" data-toggle="tab">Basic</a>
								</li>
								<li>
									<a href="#nohead" data-toggle="tab">No header</a>
								</li>
							</ul>
						</div>
						<div class="box-content box-nomargin">
							<div class="tab-content">
									<div class="tab-pane active" id="basic">
										<table class='table table-striped dataTable table-condensed table-bordered'>
                                        	  <thead>
                                                <th>编号</th>
                                                <th>用户名</th>
                                                <th>实名</th>
                                                <th>手机</th>
                                                <th>QQ</th>
                                                <th>邮箱</th>
<!--                                                <th>地址</th>-->
                                                <th>权限</th>
                                                <th>操作</th>
                                              </thead>
											<tbody>
                                              <{foreach item=colorname from=$result key=enname}>
                                              <tr>
                                                 <td><{$colorname.uid}></td>
                                                 <td><{$colorname.uname}></td>
                                                 <td><{$colorname.realname}></td>
                                                 <td><{$colorname.Phone}></td>
                                                 <td><{$colorname.QQ}></td>
                                                 <td><{$colorname.Email}></td>
<!--                                                 <td><{$colorname.Address}></td>-->
                                                 <td><{if $colorname.acl == "GBADMIN"}>管理员<{else}>用户<{/if}></td>
                                                 <td><a href="index.php?c=usersform&a=index&t=user&uid=<{$colorname.uid}>#mao">编辑</a> | <a href="javascript:del(<{$colorname.uid}>);">删除</a></td>
                                              </tr>
                                              <{/foreach}>
											</tbody>
										</table>
									</div>
									<div class="tab-pane" id="nohead">
										<table class='table table-striped dataTable dataTable-noheader table-bordered'>
											<thead>
												<tr>
                                                    <td>编号</td>
                                                    <td>用户名</td>
                                                    <th>实名</th>
                                                    <td>密码</td>
                                                    <td>权限</td>
                                                    <td>操作</td>
												</tr>
											</thead>
											<tbody>
                                              <{foreach item=colorname from=$result key=enname}>
                                              <tr>
                                                 <td><{$colorname.uid}></td>
                                                 <td><{$colorname.uname}></td>
                                                 <td><{$colorname.realname}></td>
                                                 <td><{$colorname.upass}></td>
                                                 <td><{if $colorname.acl == "GBADMIN"}>管理员<{else}>用户<{/if}></td>
                                                 <td><a href="index.php?c=usersform&a=index&t=user&uid=<{$colorname.uid}>">编辑</a> | <a href="javascript:del(<{$colorname.uid}>);">删除</a></td>
                                              </tr>                                             
                                               <{/foreach}>
											</tbody>
										</table>
									</div>

							</div>
						</div>
					</div>
				</div>
			</div>
            <div class="row-fluid">
				<div class="span12">
					<div class="box">
						<div class="box-head">
							
                           <{if $uid != 0}>
                              <h3>编辑数据</h3>
                           <{else}>
                              <h3>增加数据</h3>
                           <{/if}>
						</div>
						<div class="box-content">
						<a href="" name="mao"></a>
							<form action="#" class='validate form-horizontal'>
								<div class="control-group">
									<label for="req" class="control-label">用户名：</label>
									<div class="controls">
                                     <input type="text" name="uname" id="uname" class='required' value="<{$uname}>">
                                     <span></span>
									</div>
								</div>
                                <div class="control-group">
                                   <label for="req" class="control-label">密码：</label>
                                   <div class="controls">
                                   <input type="password" name="upass" id="upass" value="<{$upass}>">
                                   <span></span>
                                  </div>
                                </div>
                                <div class="control-group">
                                   <label for="req" class="control-label">真实名字：</label>
                                   <div class="controls">
                                   <input type="text" name="realname" id="realname" value="<{$realname}>">
                                   <span></span>
                                  </div>
                                </div>
                                
                                                                <div class="control-group">
                                   <label for="req" class="control-label">手机：</label>
                                   <div class="controls">
                                   <input type="text" name="Phone" id="Phone" value="<{$Phone}>">
                                   <span></span>
                                  </div>
                                </div>
                              
                               <div class="control-group">
                                   <label for="req" class="control-label">QQ：</label>
                                   <div class="controls">
                                   <input type="text" name="QQ" id="QQ" value="<{$QQ}>">
                                   <span></span>
                                  </div>
                                </div>
                                
                              <div class="control-group">
                                   <label for="req" class="control-label">邮箱：</label>
                                   <div class="controls">
                                   <input type="text" name="Email" id="Email" value="<{$Email}>">
                                   <span></span>
                                  </div>
                                </div>
                                
                             <div class="control-group">
                                   <label for="req" class="control-label">地址：</label>
                                   <div class="controls">
                                   <input type="text" name="Address" id="Address" value="<{$Address}>">
                                   <span></span>
                                  </div>
                                </div>
                                
                                
                                <div class="control-group">
                                   <label for="req" class="control-label">权限：</label>
                                  <div class="controls">
                                     <select name="acl" id="acl">
                                        <{if $acl == "GBADMIN"}>
                                          <option selected value="GBADMIN">管理员</option>
                                          <option value="GBUSER">用户</option>
                                        <{else}>
                                          <option selected value="GBUSER">用户</option>
                                          <option value="GBADMIN">管理员</option>                               
                                        <{/if}>
                                       </select>
                                  </div>
                                </p>
                                </div>
						<div class="form-actions">
								  <input type="button" id="ex3button" value="提交" class='btn btn-primary'>
                                  <input type="hidden" name="uid" id="uid" value="<{$uid}>">
						</div>
							</form>
						</div>
					</div>
				</div>
                
		</div>	
	</div>
</div>	
<{include file="tpl/admin/footer.html"}>